package com.hnxxxy.rewardmgr.config;

import com.hnxxxy.common.annotation.LogAnno;
import com.hnxxxy.rewardmgr.bean.NumberConfig;
import com.hnxxxy.rewardmgr.service.RewardService;
import com.hnxxxy.rewardmgr.utils.Variable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @description:
 * @projectName:lottery-project
 * @see:com.hnxxxy.rewardmgr.config
 * @author:张屹东
 * @createTime:2021/1/5 18:56
 */

@Component
public class RunnerConfig implements ApplicationRunner {
    @Autowired
    private RewardService rewardServiceImpl;

    @Override
    @LogAnno(description = "初始化数据")
    public void run(ApplicationArguments args) throws Exception {
        //得到所有学生
        Variable.numberConfigListAllOfStu.addAll(rewardServiceImpl.numberConfig(0));
        //得到所有老师
        Variable.numberConfigListAllOfTeacher.addAll(rewardServiceImpl.numberConfig(1));
        //得到所有数据
        Variable.numberConfigListAll.addAll(Variable.numberConfigListAllOfStu);
        Variable.numberConfigListAll.addAll(Variable.numberConfigListAllOfTeacher);
        //打乱顺序
        Collections.shuffle(Variable.numberConfigListAll);
    }
}
